/**
 * 首页功能
 * @file src\scripts\index.js
 * @author Verning Aulence
 * @date 2024-09-26 21:46:33
 * @description 首页功能描述
 **/

import { qe, qes } from './utils/query-elements.js';
import modal from './utils/modal.js';

/**
 * 文档加载状态监听
 */
document.addEventListener('readystatechange', () => {
  // 文档加载完成后执行
  if (document.readyState === 'complete') {
    // 相册事件
    albumEvent();
  }
});

/**
 * 相册事件
 */
function albumEvent() {
  const albumItems = qes('.album .album-item img');
  albumItems.forEach((item) => {
    item.onclick = function (e) {
      const imgURL = e.target.src;

      // 创建大图容器和图片
      const largePhotoContainer = document.createElement('div');
      largePhotoContainer.className = 'large-photo-container';
      const largePhoto = new Image();
      largePhoto.src = imgURL;
      largePhotoContainer.append(largePhoto);

      // 调用模态框
      modal.normal({
        contentPadding: 0,
        content: largePhotoContainer,
      });
    }
  });
}


